#import <Foundation/Foundation.h>
//1.
@interface DianQi : NSObject
// 基本数据类型是Object的子类吗?
@property (nonatomic,assign)int start; 	//通电时刻
@property (nonatomic,assign)int end;	//断电时刻
@property (nonatomic,assign)int p;  	//功率
-(void)on:(int)start;  	//通电
-(void)off:(int)end;     //断电
@end
@implementation DianQi
-(void)on:(int)start
{
	self.start = start;
}
-(void)off:(int)end
{
	self.end = end;
}
@end
// 2.
@interface DianQi (DianBiao)
-(int)sumDianLiang;
@end
@implementation DianQi (DianBiao)
-(int)sumDianLiang
{
	int sum = (self.end - self.start) * self.p;
	return sum;
}
@end


// 3.
@interface DianNao : DianQi
-(void)powerOnWithTime:(int)startTime;
-(void)powerOffWithTime:(int)endTime;
@end
//延展
@interface DianNao()
-(void)boradOn;
-(void)boradOff;
-(void)dianYuanOn;
-(void)dianYuanOff;
@end

@implementation DianNao
-(void)boradOn
{
	NSLog(@"主板供电");
}
-(void)boradOff
{
	NSLog(@"主板断电");
}
-(void)dianYuanOn
{
	NSLog(@"电源供电");
}
-(void)dianYuanOff
{
	NSLog(@"电源断电");
}

-(void)powerOnWithTime:(int)startTime
{
	NSLog(@"电脑开机");
	[super on:startTime];
	[self dianYuanOn];
	[self boradOn];
}
-(void)powerOffWithTime:(int)endTime
{
	NSLog(@"电脑关机");
	[self boradOff];
	[self dianYuanOff];
	[super off:endTime];
}
@end

@protocol USBProtocol
@required
-(void)transmit;
@optional
-(void)test;
@end

@interface UPan : DianQi <USBProtocol>

@end
@implementation UPan 
-(void)transmit
{
	NSLog(@"传输内容");
}
-(void)test
{
	NSLog(@"测试Upan");
}
@end

int main()
{
	// DianNao * dn1 = [[DianNao alloc]init];
	// [dn1 powerOnWithTime:0];
	// [dn1 powerOffWithTime:10];
	// dn1.p = 1;
	// NSLog(@"电脑十个小时的耗电量为 %d kw/h",[dn1 sumDianLiang]);

}